//
//  HeartViewController.m
//  happyHealthyWalk
//
//  Created by newhuidong on 16/2/22.
//  Copyright © 2016年 HuiDong. All rights reserved.
//

#import "HeartViewController.h"
#import "Header.h"
#import "HeartTableViewCell.h"
#import "Data.h"
#import "SubmitViewController.h"

@interface HeartViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * tableView;

@property(nonatomic,strong)NSArray * dataArr;


@end

@implementation HeartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor redColor];
    
    self.tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH-64-40) style:UITableViewStylePlain];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.rowHeight=80;
    
    
    
    [self.view addSubview:self.tableView];
    
    UIButton * button =[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame=CGRectMake(20, 0,self.tableView.frame.size.width-40, 44);
    
    
    button.layer.cornerRadius=5;
    [button setTitle:@"我要投稿:分享健康心得" forState:0];
    [button setTitleColor:[UIColor whiteColor] forState:0];


    button.backgroundColor=GreenColor;
    //我要投稿
    [button addTarget:self action:@selector(touGao:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIView * view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 60)];
    [view addSubview:button];
    
    
    
    self.tableView.tableFooterView=view;
    
    _dataArr=@[@{@"imageName":@"heartHead",@"title":@"无形之刃，最为致命",@"detail":@"就又买了一葫芦酒，包了那两块牛肉，留下些碎银子。把花枪挑着酒葫芦，怀内揣了牛肉，叫声相扰，便出篱笆门，仍旧迎着朔风回来。"},@{@"imageName":@"heartHead",@"title":@"林教头风雪山神庙",@"detail":@"凛凛严凝雾气昏，空中祥瑞降纷纷。须臾四野难分路，顷刻千山不见痕。"},@{@"imageName":@"heartHead",@"title":@"林教头风雪山神庙",@"detail":@"凛凛严凝雾气昏，空中祥瑞降纷纷。须臾四野难分路，顷刻千山不见痕。"},@{@"imageName":@"heartHead",@"title":@"林教头风雪山神庙",@"detail":@"凛凛严凝雾气昏，空中祥瑞降纷纷。须臾四野难分路，顷刻千山不见痕。"},@{@"imageName":@"heartHead",@"title":@"林教头风雪山神庙",@"detail":@"凛凛严凝雾气昏，空中祥瑞降纷纷。须臾四野难分路，顷刻千山不见痕。"}];
    
    
    
}
-(void)touGao:(UIButton *)button{
    
    UIStoryboard * story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    SubmitViewController * submit=[story instantiateViewControllerWithIdentifier:@"SubmitViewController"];
    
    [self.parentController.navigationController pushViewController:submit animated:YES];
    
    
    
    
    
    NSLog(@"我要投稿");
    
    
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return 5;
    
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    HeartTableViewCell * cell=[HeartTableViewCell heartcellWithTableView:tableView];
    
    cell.dic=self.dataArr[indexPath.row];
    
    
    return cell;
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row==0) {
        
        NSLog(@"第1行");
    }else if (indexPath.row==1){
        
        NSLog(@"第2行");
    }else if (indexPath.row==2){
        
        NSLog(@"第3行");
    }else if (indexPath.row==3){
        NSLog(@"第4行");
        
    }else if (indexPath.row==4){
        NSLog(@"第5行");
        
    }
    
    
    
    
}

@end
